const app = getApp()
import dateFormat from "../../utils/dateFormat" 

Page({
  /**
   * 页面的初始数据
   */
  data: {
    base_url: "https://vip.join.ink/",
    order_id: "",
    orderInfo: [],
    can_refund: false,
    has_wl: false,
    com: "",
    nu: ""
  },


  appraise(){

  },


  refund() {
    let order_id = this.data.order_id
    wx.navigateTo({
      url: '/pages/refund/refund?order_id=' + order_id,
    })
  },


  fetch(order_id) {
    app.request("/user/search_haspayDetail", {
      data: {
        order_no: order_id
      }
    }).then(res => {
      // dateFormat
     let  orderInfo = res.data.data
     orderInfo[0].create_time=dateFormat("YYYY-mm-dd HH:MM",parseInt(orderInfo[0].create_time)*1000)
      this.setData({
        orderInfo,
        can_refund: res.data.data[0].type,
        com: res.data.data[0].wuliu_no,
        nu: res.data.data[0].shipment_number,
      })
      console.log(res, "订单详情");
    })
  },


  logistics() {
    let orderInfo = this.data.orderInfo
    orderInfo = JSON.stringify(orderInfo)
    wx.navigateTo({
      url: `/pages/logistics/logistics?orderInfo=${orderInfo}`,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */

  onLoad: function (options) {
    // console.log(options,"options");
    let order= JSON.parse(options.order)
    console.log(order,"order");
    let order_id = order.id
    let state = order.state
    this.setData({
      order_id,
      has_wl: state
    })
    this.fetch(order_id)
  },




  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let order_id = this.data.order_id
    this.fetch(order_id)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})